using System;
using SpiderMaster.AspNet.TradingSystem.BusinessLogicLayer;

namespace SpiderMaster.AspNet.TradingSystem.UI
{
    public partial class Error : TradingCenterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AdministratorPanel.Visible = true; // IsAdministrator;

            if (true && Server.GetLastError().IsNotNull())//IsAdministrator)
                AdministratorLabel.Text = GetError();
            else AdministratorLabel.Text = "Your current privleges dont allow you to view Exceptions!";

            try { MailLink.NavigateUrl = "mailto:" + SiteSettings.Current.SiteEmailAddress; }
            catch { MailLink.NavigateUrl = "#"; }

            // Display information on the page being processed.
            // Display information on the (real) error that occurred.
        }
        private string GetError()
        {
            if (Server.GetLastError().InnerException.IsNotNull())
                return "<b>URL = </b>".Add(Request.Path).Add("<br /><b>QueryString = </b>").Add(Request.QueryString.ToString()) +
                    "<p><b>Error details</b><p>".Add(Server.HtmlEncode(Server.GetLastError().InnerException.ToString().Replace("\n", "<BR />")));
            else return "<b>URL = </b>".Add(Request.Path).Add("<br /><b>QueryString = </b>").Add(Request.QueryString.ToString()) +
                "<p><b>Error details</b><p>".Add(Server.HtmlEncode(Server.GetLastError().ToString().Replace("\n", "<BR />")));
        }
    }
}